/*
 * @lc app=leetcode.cn id=693 lang=typescript
 *
 * [693] 交替位二进制数
 */

// @lc code=start
function hasAlternatingBits(n: number): boolean {
    let last = "1";
    return n
        .toString(2)
        .split("")
        .every((i) => {
            if (i === last) {
                last = last === "1" ? "0" : "1";
                return true;
            }
            return false;
        });
}
// @lc code=end
